<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/


Route::group(['prefix' => 'admin','middleware'=>'adminAuth'],function($app){
    Route::any('/', "Admin\HomeController@index");
    Route::resource("home","Admin\HomeController",['only' => ['index']]);

    Route::post("userinfo/savemessage", array('as' => 'admin.userinfo.savemessage', 'uses' => "Admin\UserInfos\UserInfosController@savemessage"));
    Route::post("userinfo/savephoto", array('as' => 'admin.userinfo.savephoto', 'uses' => "Admin\UserInfos\UserInfosController@savephoto"));
    Route::post("userinfo/resetpassword", array('as' => 'admin.userinfo.resetpassword', 'uses' => "Admin\UserInfos\UserInfosController@resetpwd"));
    Route::get("userinfo", array('as' => 'admin.userinfo', 'uses' => "Admin\UserInfos\UserInfosController@index"));
    //Route::resource("userinfo","Admin\UserInfos\UserInfosController",['only' => ['index']]);
    Route::post("post/page", array('as' => 'admin.post.page', 'uses' => "Admin\CMS\PostController@page"));



    //Auth部分功能
    Route::resource("resource","Admin\Auth\ResourceController");
    Route::resource("role","Admin\Auth\RoleController");
    Route::resource("adminusers","Admin\Auth\AdminUsersController");
    Route::post("adminusers/page", array('as' => 'admin.adminusers.page', 'uses' => "Admin\Auth\AdminUsersController@page"));
    Route::post("adminusers/saveUserRole", array('as' => 'admin.adminusers.saveUserRole', 'uses' => "Admin\Auth\AdminUsersController@saveUserRole"));
    Route::post("adminusers/resetpwd", array('as' => 'admin.adminusers.resetpwd', 'uses' => "Admin\Auth\AdminUsersController@resetpwd"));
    Route::post("resource/updateCtrees", array('as' => 'admin.resource.updateCtrees', 'uses' => "Admin\Auth\ResourceController@updateCtrees"));
    Route::post("role/page", array('as' => 'admin.role.page', 'uses' => "Admin\Auth\RoleController@page"));
    Route::post("role/saveRoleResource", array('as' => 'admin.role.saveRoleResource', 'uses' => "Admin\Auth\RoleController@saveRoleResource"));




    //CMS部分功能
    Route::resource("post","Admin\CMS\PostController");
    Route::post("post/deletePostHistory", array('as' => 'admin.post.deletePostHistory', 'uses' => "Admin\CMS\PostController@deletePostHistory"));


    Route::resource("category","Admin\CMS\CategoryController");
     Route::post("category/updateCtrees", array('as' => 'admin.category.updateCtrees', 'uses' => "Admin\CMS\CategoryController@updateCtrees"));
    Route::resource("tag","Admin\CMS\TagController");
    Route::post("tag/page", array('as' => 'admin.tag.page', 'uses' => "Admin\CMS\TagController@page"));
    Route::resource("postpro","Admin\CMS\PostProController");
    Route::post("postpro/page", array('as' => 'admin.postpro.page', 'uses' => "Admin\CMS\PostProController@page"));


    //file
    Route::post("file/upload", array('as' => 'admin.file.upload', 'uses' => "Admin\File\FileUploadController@uploadfile"));
    Route::post("file/uploadSummernotefile", array('as' => 'admin.file.uploadSummernotefile', 'uses' => "Admin\File\FileUploadController@uploadSummernotefile"));
    Route::post("file/uploadfile", array('as' => 'admin.file.uploadfile', 'uses' => "Admin\File\FileUploadController@uploadJQfile"));
    Route::resource("filemanage","Admin\File\FilemanageController");
//    Route::post("fileedit/getFilesNameList","Admin\File\FilecontentEditController@getFilesNameList");
    Route::resource("filecontents","Admin\Sys\FilecontentsController");
    Route::post("filecontents/updateCtrees", array('as' => 'admin.filecontents.updateCtrees', 'uses' => "Admin\Sys\FilecontentsController@updateCtrees"));
    Route::post("filecontents/getTreeData", array('as' => 'admin.filecontents.getTreeData', 'uses' => "Admin\Sys\FilecontentsController@getTreeData"));
    Route::post("filecontents/getContentHistory", array('as' => 'admin.filecontents.getContentHistory', 'uses' => "Admin\Sys\FilecontentsController@getContentHistory"));
    Route::post("filecontents/getContentHistoryById", array('as' => 'admin.filecontents.getContentHistoryById', 'uses' => "Admin\Sys\FilecontentsController@getContentHistoryById"));

    //system
    Route::resource("sysparam","Admin\Sys\SysparamController");
    Route::post("sysparam/page", array('as' => 'admin.sysparam.page', 'uses' => "Admin\Sys\SysparamController@page"));
    Route::post("sysparam/saveSeo", array('as' => 'admin.sysparam.saveSeo', 'uses' => "Admin\Sys\SysparamController@saveSeo"));
    Route::get("seo",array('as' => 'admin.seo', 'uses' => "Admin\Sys\SysparamController@seoshow"));

    //email config
    Route::resource("email","Admin\Promotion\EmailController");
    Route::post("email/testmail",array('as' => 'admin.email.testmail', 'uses' => "Admin\Promotion\EmailController@testmail"));
    //ansyic
    Route::get("async",array('as' => 'admin.sysparam.async', 'uses' => "Admin\Sys\SysparamController@async"));
    Route::post("saveasync",array('as' => 'admin.sysparam.saveasync', 'uses' => "Admin\Sys\SysparamController@saveasync"));

    //联系我们
    Route::resource("contacts","Admin\Sys\ContactsController");
    Route::post("contacts/page", array('as' => 'admin.contacts.page', 'uses' => "Admin\Sys\ContactsController@page"));
    //rebots设置
    Route::resource("robots","Admin\Sys\RobotsController");

    //sitemap 设置
    Route::resource("sitemap","Admin\Promotion\SitemapController");

    //网站静态文件编辑
    Route::resource("file_edit","Admin\Sys\FileEditController");
    Route::post("file_edit/getfile", array('as' => 'admin.file_edit.getfile', 'uses' => "Admin\Sys\FileEditController@getfile"));
    //广告管理
    Route::resource("ads","Admin\Promotion\AdController");
    Route::resource("ad_position","Admin\Promotion\AdPositionController");
    Route::post("ads/page", array('as' => 'admin.ads.page', 'uses' => "Admin\Promotion\AdController@page"));
    Route::post("ad_position/page", array('as' => 'admin.ads.page', 'uses' => "Admin\Promotion\AdPositionController@page"));

});

Route::get('admin/logout', array('as' => 'admin.logout', 'uses' => 'Admin\Auth\AuthController@getLogout'));
Route::get('admin/login', array('as' => 'admin.login', 'uses' => 'Admin\Auth\AuthController@getLogin'));
Route::post('admin/login', array('as' => 'admin.login.post', 'uses' => 'Admin\Auth\AuthController@postLogin'));



Route::group(['middleware'=>['assetsFilter','seoFill']],function($app){
    Route::any('/', "Customer\HomeController@index");
    Route::get('/sitemap.xml', array('as' => 'sitemap', 'uses' => "Customer\CommonController@sitemap"));
    Route::get('/rss', array('as' => 'rss', 'uses' => "Customer\CommonController@rss"));
    Route::get('/{category}', array('as' => 'category', 'uses' => "Customer\HomeController@categoryshow"));
    Route::post('/savecontact', array('as' => 'savecontact', 'uses' => "Customer\HomeController@savecontact"));
    Route::get('/{category}/{subcategory}', array('as' => 'category.subcategory', 'uses' => "Customer\HomeController@subcategoryshow"));

});



\Illuminate\Support\Facades\Event::listen('illuminate.query', function($sql, $param)

{

    \Illuminate\Support\Facades\Log::info($sql . ", with[" . join(',', $param) ."]");

});
